package com.ssy.lingxi.search.repository;

import com.ssy.lingxi.search.entity.CommodityCollect;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

/**
 * 商品收藏持久化层
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/9/2
 */
public interface CommodityCollectRepository extends JpaRepository<CommodityCollect,Long>, JpaSpecificationExecutor<CommodityCollect> {

    List<CommodityCollect> findByCommodityIdAndMemberIdAndMemberRoleIdAndUserIdAndShopId(Long commodityId, Long memberId, Long memberRoleId, Long userId, Long shopId);

    Boolean existsByCommodityIdAndMemberIdAndMemberRoleIdAndUserIdAndShopId(Long commodityId, Long memberId, Long memberRoleId, Long userId, Long shopId);

    Integer countByCommodityIdAndShopId(Long commodityId, Long shopId);

    Page<CommodityCollect> findByMemberIdAndMemberRoleIdAndUserIdAndShopId(Long memberId, Long memberRoleId, Long userId, Long shopId, Pageable page);

    Page<CommodityCollect> findByMemberIdAndMemberRoleIdAndUserId(Long memberId, Long memberRoleId, Long userId, Pageable page);
}
